package kr.pe.johnkim.waiting.mobile.dao;

import kr.pe.johnkim.waiting.mobile.domain.WaitingSMS;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

/**
 * Waiting 인증 관련 Dao 구현 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 5. 3.
 */
@Repository
public class WaitingCertificationDaoImpl extends SqlSessionDaoSupport implements WaitingCertificationDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(WaitingEventDaoImpl.class);

    /**
     * 인증 번호를 등록 한다.
     *
     * @param waitingSMS
     */
    @Override
    public void registerCertification(WaitingSMS waitingSMS) {
        logger.info("registerCertification");
        this.getSqlSession().insert("WAITING_CERTIFICATIONS.registerCertification", waitingSMS);
    }

    /**
     * 해당 멤버의 인증 정보가 있는지 확인 한다.
     *
     * @param waitingSMS
     * @return
     */
    @Override
    public WaitingSMS selectExistCertificationInformation(WaitingSMS waitingSMS) {
        logger.info("selectExistCertificationInformation");
        return (WaitingSMS)this.getSqlSession().selectOne("WAITING_CERTIFICATIONS.selectExistCertificationInformation", waitingSMS);
    }

    /**
     * 해당 멤버의 인증 정보를 가져 온다.
     *
     * @param waitingSMS
     * @return
     */
    @Override
    public WaitingSMS selectCertificationInformation(WaitingSMS waitingSMS) {
        logger.info("selectCertificationInformation");
        return (WaitingSMS)this.getSqlSession().selectOne("WAITING_CERTIFICATIONS.selectCertificationInformation", waitingSMS);
    }

    /**
     * 해당 인증 정보를 비활성화 한다.
     *
     * @param waitingSMS
     */
    @Override
    public void updateDeactivateCertification(WaitingSMS waitingSMS) {
        logger.info("updateDeactivateCertification");
        this.getSqlSession().update("WAITING_CERTIFICATIONS.updateDeactivateCertification", waitingSMS);
    }
}
